package com.example.administrator.pomelostreet.pinpai.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.pomelostreet.R;
import com.example.administrator.pomelostreet.pinpai.bean.PinPai_TwoBean;

import java.util.List;

/**
 * Created by yq on 2017/2/10.
 */

public class PinPai_two_RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context mContext;
    private List<PinPai_TwoBean> mList;


    public PinPai_two_RecyclerViewAdapter(Context mContext,List<PinPai_TwoBean> mList){
        this.mContext=mContext;
       this.mList= mList;
    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(mContext).inflate(R.layout.pinpai_twoactivity_item,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if(holder instanceof MyViewHolder){
            PinPai_TwoBean pinPai_twoBean = mList.get(position);
            Glide.with(mContext).load(pinPai_twoBean.getPicture()).into(((MyViewHolder) holder).iv_pinpai_two);
            ((MyViewHolder)holder).text_one.setText(pinPai_twoBean.getName());
            ((MyViewHolder)holder).text_two.setText("￥"+pinPai_twoBean.getVip_price());

        }



    }

    @Override
    public int getItemCount() {
        return  mList.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {

        private ImageView iv_pinpai_two;
        private TextView text_one, text_two;
        public MyViewHolder(View itemView) {
            super(itemView);
            iv_pinpai_two = (ImageView) itemView.findViewById(R.id.pinpai_twoactivity_img);
            text_one = (TextView) itemView.findViewById(R.id.pinpai_twoactivity_tv1);
            text_two = (TextView) itemView.findViewById(R.id.pinpai_twoactivity_tv2);
        }
    }
}
